package DataBaseHelper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import constrants.UserConstrant;

public class UserDbHelper extends SQLiteOpenHelper {
    private static final String SQL_CREATE_ENTRIES =
            "CREATE TABLE " + UserConstrant.UsersEntry.TABLE_NAME + " (" +
                    UserConstrant.UsersEntry.USER_ID + " VARCHAR(50), " +
                    UserConstrant.UsersEntry.USERNAME + " VARCHAR(30) PRIMARY KEY, " +
                    UserConstrant.UsersEntry.AVATAR + " VARCHAR(1000), " +
                    UserConstrant.UsersEntry.INTRODUCE + " TEXT, " +
                    UserConstrant.UsersEntry.SEX + " VARCHAR(5), " +
                    UserConstrant.UsersEntry.PASS_WORD + " VARCHAR(20)" +
                    ")";

    private static final String SQL_DELETE_ENTRIES =
            "DROP TABLE IF EXISTS " + UserConstrant.UsersEntry.TABLE_NAME;

    public static final int DATABASE_VERSION = 1;
    public static final String DATABASE_NAME = "users.db";

    private Context mContext;

    public UserDbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        mContext = context;
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL(SQL_CREATE_ENTRIES);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        sqLiteDatabase.execSQL(SQL_DELETE_ENTRIES);
    }
}
